package gx.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name = "t_sale")
public class Sale implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue
	private Integer id;  //销售订单编号
	private BigDecimal cost; //销售总金额
	private Integer pay_type; //支付类型 0:全款 1:欠款
	@Lob
	private String remark;    //销售订单备注
	private Date sale_date;    //销售日期
	private String sn;     //销售订单序列号 
	private Integer status;  //销售状态 0:草稿 1:已出单 2:已出库 3：退货
	
	//映射关系
	//销售订单-管理员 多对一
	@ManyToOne
	@JoinColumn(name="mgr_id")
	private Manager manager;
	
	//销售订单-客户 多对一
	@ManyToOne
	@JoinColumn(name="cust_id")
	private Customer customer;
	
	//订单-订单项的一对多
	@OneToMany(cascade = { CascadeType.ALL })
	@JoinColumn(name = "sale_id")
	private List<SaleItem> itemList = new ArrayList<SaleItem>();
	


	public List<SaleItem> getItemList() {
		return itemList;
	}

	public void setItemList(List<SaleItem> itemList) {
		this.itemList = itemList;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public BigDecimal getCost() {
		return cost;
	}

	public void setCost(BigDecimal cost) {
		this.cost = cost;
	}

	public Integer getPay_type() {
		return pay_type;
	}

	public void setPay_type(Integer pay_type) {
		this.pay_type = pay_type;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Date getSale_date() {
		return sale_date;
	}

	public void setSale_date(Date sale_date) {
		this.sale_date = sale_date;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Manager getManager() {
		return manager;
	}

	public void setManager(Manager manager) {
		this.manager = manager;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Override
	public String toString() {
		return "Sale [id=" + id + ", cost=" + cost + ", pay_type=" + pay_type + ", remark=" + remark + ", sale_date="
				+ sale_date + ", sn=" + sn + ", status=" + status + ", manager=" + manager + ", customer=" + customer
				+ "]";
	}
	
	
	

}
